package com.ViewModel;

import com.BaseDeDatos.Conexion;

import gueei.binding.Binder;
import gueei.binding.Command;
import gueei.binding.observables.StringObservable;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.StrictMode;
import android.view.View;

public class MenuViewModel extends Activity {

	
		public StringObservable Greeting = new StringObservable("Hola al mundo de Android Binding");
		
	    public Command ChangeGreeting = new Command(){
	    	public void Invoke(View arg0,Object... arg1){
	    		Greeting.set("Menu Principal");
	    		
	    	}
	    	
	    };

	    
	    public Command ListViewViewModel = new Command(){
	    	public void Invoke(View arg0,Object... arg1){
	    		listViewViewModel();
	    	}
	    	
	    };
	    private void listViewViewModel()
	    {
    		Intent intent = new Intent(this,ListViewViewModel.class);
    		startActivity(intent);
    		finish();
	    }
	    
	    
	    public Command LoginViewModel = new Command(){
	    	public void Invoke(View arg0,Object... arg1){
	    		loginViewModel();
	    	}
	    	
	    };
	    private void loginViewModel()
	    {
    		Intent intent = new Intent(this,LoginViewModel.class);
    		startActivity(intent);
    		finish();
	    }

	    public Command ConvertidorViewModel = new Command(){
	    	public void Invoke(View arg0,Object... arg1){
	    		convertidorViewModel();
	    	}
	    	
	    };
	    public Command GridViewModel = new Command(){
	    	public void Invoke(View arg0,Object... arg1){
	    		gridViewModel();
	    	}
	    	
	    };
	    
	    private void convertidorViewModel()
	    {
    		Intent intent = new Intent(this,ConvertidorViewModel.class);
    		startActivity(intent);
    		finish();
	    }
	  
	    private void gridViewModel()
	    {
    		Intent intent = new Intent(this,GridViewModel.class);
    		startActivity(intent);
    		finish();
	    }
	    
	    public Command ProbarConexion = new Command(){
	    	public void Invoke(View arg0,Object... arg1){
	    		ProbarConexion();
	    	}
	    	
	    };
	    private void ProbarConexion()
	    {
    		Conexion.EjecutarPruebaDeConexion();
	    }
	    //ProbarConexion
	    
	    @SuppressWarnings("deprecation")
		@Override
		public void onCreate(Bundle savedInstanceState) {
	    	 StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
	    	 StrictMode.setThreadPolicy(policy);
	    	super.onCreate(savedInstanceState);
	    	
	    	Binder.setAndBindContentView(this, R.layout.menu_view, this);
	    }
}
